package com.taikang.hmp.hbusiness.diabetes.measure.version.action.intface;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.taikang.hmp.frame.common.TKException;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.datastructre.support.ResponseDto;
import com.taikang.hmp.frame.common.web.action.BaseAction;
import com.taikang.hmp.hbusiness.diabetes.measure.version.service.IVersionService;

/** 
 * 版本信息
 * author:qrp
 * time:2016年2月19日 上午10:21:00
 */
public class VersionAction extends BaseAction{
	private static final long serialVersionUID = 1L;
	private static Logger logger = LoggerFactory.getLogger(VersionAction.class);
	
	private IVersionService versionService;
	
	public IVersionService getVersionService() {
		return versionService;
	}

	public void setVersionService(IVersionService versionService) {
		this.versionService = versionService;
	}

	public String executeAction() {
		if ("getVersion".equals(requestDto.getMethod())) { 
			logger.info("--【获取版本号】: method getVersion --");
			return getVersion();
		} else {
			logger.info("executeAction 里没有配置"+ requestDto.getMethod() +"方法!");
			throw new TKException("no support method:" + requestDto.getMethod());
		}
	}
	
	/**
	 * 获取版本号更新信息
	 * @return
	 */
	public String getVersion(){
		ResponseDto responseDto = new ResponseDto();
		//获取参数
	    Dto paramDto = requestDto.getRequestlist().get(0);
//	    paramDto = super.appendRequestBase(paramDto, requestDto);
	    
	    List<Dto> result = versionService.getVersion(paramDto);	
	    Dto resultDto = new BaseDto();
		resultDto.put("resultlist", result);
		responseDto.pushResultDto(resultDto);
		//
		super.setDataMap(responseDto);
		return SUCCESS;
	}
}
